package com.edu.user.controller;

import com.edu.entity.HfdUserInfo;
import com.edu.user.service.IHfdUserInfoService;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 曾宪霖
 * @since 2021-04-13
 */
@RestController
@RequestMapping("/sso")
public class HfdUserInfoController {

    @Autowired
    private IHfdUserInfoService hfdUserInfoService;

    /**
     * 用户登录
     *
     * @param hfdUserInfo
     * @return
     */
    @RequestMapping("login")
    public Result login(@RequestBody HfdUserInfo hfdUserInfo) {
        return hfdUserInfoService.login(hfdUserInfo);
    }

    /**
     * 发送短信验证码
     *
     * @param phone
     * @return
     */
    @RequestMapping("sendCode")
    public Result sendCode(@RequestParam String phone) {
        return hfdUserInfoService.sendCode(phone);
    }

    /**
     * 前台用户注册
     *
     * @param hfdUserInfo
     * @return
     */
    @RequestMapping("register")
    public Result register(@RequestBody HfdUserInfo hfdUserInfo) {
        return hfdUserInfoService.register(hfdUserInfo);
    }

    /**
     * 获取当前用户的登录信息
     *
     * @return
     */
    @RequestMapping("getCurrentUser")
    public Result getCurrentUser() {
        return hfdUserInfoService.getCurrentUser();
    }

    /**
     * 查询所有用户信息
     *
     * @return
     */
    @RequestMapping("queryHfdUser")
    public Result queryHfdUser() {
        return hfdUserInfoService.queryHfdUser();
    }

    /**
     * 增加用户
     *
     * @param hfdUserInfo
     * @return
     */
    @RequestMapping("addHfdUser")
    public Result addHfdUser(@RequestBody HfdUserInfo hfdUserInfo) {
        return hfdUserInfoService.addHfdUser(hfdUserInfo);
    }

    /**
     * 根据user_id删除用户
     *
     * @param hfdUserInfo
     * @return
     */
    @RequestMapping("deleteHfdUserById")
    public Result deleteHfdUserById(@RequestBody HfdUserInfo hfdUserInfo) {
        return hfdUserInfoService.deleteHfdUserById(hfdUserInfo);
    }

    /**
     * 根据user_id修改用户信息
     *
     * @param hfdUserInfo
     * @return
     */
    @RequestMapping("updateHfdUserById")
    public Result updateHfdUserById(@RequestBody HfdUserInfo hfdUserInfo) {
        return hfdUserInfoService.updateHfdUserById(hfdUserInfo);
    }

}
